<?php
class Admin_View_Helper_ResourcePath
{
    public $view;

    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    public function ResourcePath()
    {
    	$resource = new AclResourcesView();		
		$arr = $resource->getAllResource();				
        echo '<ul id="browser" class="filetree">';
		foreach($arr as $id=>$val){
    		echo '<li><span class="folder"  sid="'.$val['id'].'">'.$val['title'].'</span>';
    		if ($val['children_count']>0) {
    			$this->_resource_list($val['children']);
    		}
    		echo "</li>";
		}
		echo '</ul>';
    }
    
    private function _resource_list($arr)
    {
    	
    	echo '<ul>';
    	foreach($arr as $id=>$val){
    		if ($val['children_count'] > 0) {
    			echo '<li><span class="folder" sid="'.$val['id'].'">'.$val['title'].'</span>';
    			$this->_resource_list($val['children']);
    		}
    		else {
    			echo '<li><span class="file" sid="'.$val['id'].'">'.$val['title'].'</span>';
    		}
    		echo "</li>";
    	}
		echo '</ul>';
    }
    
}

